package com.mk.settlement.task.impl;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mk.settlement.service.SchedulerService;
import com.mk.settlement.service.SettlementRegularService;
import com.mk.settlement.task.SettlementTaskJob;

@Service(value = "settlementThresholdWeekTaskJob")
public class SettlementThresholdWeekTaskJob implements SettlementTaskJob {

    @Resource
    private SettlementRegularService settlementThresholdWeekService;

    @Resource
    private SchedulerService schedulerService;

    private static final String TASK_NAME = "阈值周结_累加定时任务";

    @Override
    public void execute() {

        if (schedulerService.havePermission(TASK_NAME)) {
            log.info("阈值周结_累加 execute at: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            // 生成阈值月结算数据
            settlementThresholdWeekService.doSettlement();
        } else {
            log.info("没有获得" + TASK_NAME + "运行权限.");
        }
    }
}
